package com.example.photobrowser;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;

import android.media.ExifInterface;

public class ImageAdapter extends BaseAdapter{
	  private Context mContext;
	  // references to our images
	  private Integer[] mThumbIds = { R.drawable.amsterdam, R.drawable.arena, R.drawable.beeren };
	  		/*, R.drawable.bilbao, R.drawable.bohnen, 
            R.drawable.boule, R.drawable.buschberg, R.drawable.catedraldelbuenpastor, R.drawable.donostia, 
            R.drawable.drachen, R.drawable.eis, R.drawable.eisbrocken, R.drawable.eisholz, R.drawable.falke,
            R.drawable.feld, R.drawable.feuerbluete, R.drawable.fractions, R.drawable.frosch, R.drawable.fruehling,
            R.drawable.gang, R.drawable.gridlayout, R.drawable.gruen, R.drawable.hdr, R.drawable.lampe, R.drawable.leben,
            R.drawable.leckerbissen, R.drawable.lndw, R.drawable.mainframe};*/

	    public ImageAdapter(Context c) {
	        mContext = c;
	    }

	    public int getCount() {
	        return mThumbIds.length;
	    }

	    public Object getItem(int position) {
	        return mThumbIds[position];
	    }

	    public long getItemId(int position) {
	        return (int) mThumbIds[position];
	    }

	    // create a new ImageView for each item referenced by the Adapter
	    public View getView(final int position, View convertView, ViewGroup parent) {
	        ImageView imageView;
	        if (convertView == null) {  // if it's not recycled, initialize some attributes
	            imageView = new ImageView(mContext);
	            imageView.setLayoutParams(new GridView.LayoutParams(185, 185));
	            imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
	            imageView.setPadding(8, 8, 8, 8);    
	        } else {
	            imageView = (ImageView) convertView;
	        }
	        
	        int height = imageView.getHeight();
	        int width = imageView.getWidth(); 
	        imageView.setImageResource(mThumbIds[position]);
	        return imageView;
	    }
	    	    
	}

